﻿<navigation:Page x:Class="LEEAAttendanceControl.Views.Shifts"
           xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"
           xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
           xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
           xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
           xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
           xmlns:riaControls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.DomainServices"
           xmlns:my="clr-namespace:LEEAAttendanceControl.Web.Services"
           mc:Ignorable="d"
           xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
           d:DesignWidth="640" d:DesignHeight="480"
           Title="Shifts">
    <Grid x:Name="LayoutRoot">
        <ScrollViewer VerticalScrollBarVisibility="Auto">
            <StackPanel Orientation="Vertical">
                <riaControls:DomainDataSource x:Name="ShiftsDataSource" QueryName="GetShiftsByCompanyID" AutoLoad="True"
                                              PageSize="10" LoadSize="20" LoadingData="ShiftsDataSource_LoadingData">
                    <riaControls:DomainDataSource.DomainContext>
                        <my:LEEAContext/>
                    </riaControls:DomainDataSource.DomainContext>
                </riaControls:DomainDataSource>

                <Grid Background="#404041">
                    <TextBlock Text="Shifts" FontSize="14" FontWeight="Bold" Foreground="White" Margin="5,2,2,2"
                               VerticalAlignment="Center"/>
                </Grid>

                <sdk:DataGrid x:Name="shiftsGrid" AutoGenerateColumns="False" IsReadOnly="True"
                              ItemsSource="{Binding Data, ElementName=ShiftsDataSource}"
                              SelectionChanged="shiftsGrid_SelectionChanged">
                    <sdk:DataGrid.Columns>
                        <sdk:DataGridTemplateColumn Header="Shift ID" CanUserReorder="True" CanUserResize="True"
                                                    Width="100">
                            <sdk:DataGridTemplateColumn.CellTemplate>
                                <DataTemplate>
                                    <Grid Margin="0" Background="{Binding Color}">
                                        <sdk:Label x:Name="shiftIDLabel" Content="{Binding ShiftID}" Margin="5,0,0,0"
                                                   Foreground="{Binding ForeColor}" VerticalAlignment="Center" Height="25"/>
                                    </Grid>
                                </DataTemplate>
                            </sdk:DataGridTemplateColumn.CellTemplate>
                        </sdk:DataGridTemplateColumn>
                        <sdk:DataGridTemplateColumn Header="Shift" CanUserReorder="True" CanUserResize="True" Width="150">
                            <sdk:DataGridTemplateColumn.CellTemplate>
                                <DataTemplate>
                                    <Grid Margin="0" Background="{Binding Color}">
                                        <sdk:Label x:Name="shiftNameLabel" Content="{Binding ShiftName}"
                                                   VerticalAlignment="Center" Margin="5,0,0,0" Foreground="{Binding ForeColor}"/>
                                    </Grid>
                                </DataTemplate>
                            </sdk:DataGridTemplateColumn.CellTemplate>
                        </sdk:DataGridTemplateColumn>
                        <sdk:DataGridTemplateColumn Header="Time From" CanUserReorder="True" CanUserResize="True" Width="130">
                            <sdk:DataGridTemplateColumn.CellTemplate>
                                <DataTemplate>
                                    <Grid Margin="0" Background="{Binding Color}">
                                        <sdk:Label x:Name="shiftFromLabel" Content="{Binding TimeFrom
                                                                                     , StringFormat='hh:mm tt'}"
                                                   VerticalAlignment="Center" Margin="5,0,0,0" Foreground="{Binding ForeColor}"/>
                                    </Grid>
                                </DataTemplate>
                            </sdk:DataGridTemplateColumn.CellTemplate>
                        </sdk:DataGridTemplateColumn>
                        <sdk:DataGridTemplateColumn Header="Time To" CanUserReorder="True" CanUserResize="True" Width="130">
                            <sdk:DataGridTemplateColumn.CellTemplate>
                                <DataTemplate>
                                    <Grid Margin="0" Background="{Binding Color}">
                                        <sdk:Label x:Name="shiftToLabel" Content="{Binding TimeTo, StringFormat='hh:mm tt'}"
                                                   VerticalAlignment="Center" Margin="5,0,0,0" Foreground="{Binding ForeColor}"/>
                                    </Grid>
                                </DataTemplate>
                            </sdk:DataGridTemplateColumn.CellTemplate>
                        </sdk:DataGridTemplateColumn>
                        <sdk:DataGridTemplateColumn Header="Break Time" CanUserReorder="True" CanUserResize="True" Width="120">
                            <sdk:DataGridTemplateColumn.CellTemplate>
                                <DataTemplate>
                                    <Grid Margin="0" Background="{Binding Color}">
                                        <sdk:Label x:Name="shiftBreakLabel" Content="{Binding BreakTime}" Margin="5,0,0,0"
                                                   VerticalAlignment="Center"  Foreground="{Binding ForeColor}"/>
                                    </Grid>
                                </DataTemplate>
                            </sdk:DataGridTemplateColumn.CellTemplate>
                        </sdk:DataGridTemplateColumn>
                        <sdk:DataGridTemplateColumn Header="Available From" CanUserReorder="True" CanUserResize="True"
                                                    Width="133">
                            <sdk:DataGridTemplateColumn.CellTemplate>
                                <DataTemplate>
                                    <Grid Margin="0" Background="{Binding Color}">
                                        <sdk:Label x:Name="shiftDateFromLabel" Content="{Binding DateFrom
                                                                                         , StringFormat='dd/MM/yyyy'}"
                                                   VerticalAlignment="Center" Margin="5,0,0,0" Foreground="{Binding ForeColor}"/>
                                    </Grid>
                                </DataTemplate>
                            </sdk:DataGridTemplateColumn.CellTemplate>
                        </sdk:DataGridTemplateColumn>
                        <sdk:DataGridTemplateColumn CanUserReorder="True" CanUserResize="True" Width="20">
                            <sdk:DataGridTemplateColumn.CellTemplate>
                                <DataTemplate>
                                    <Grid Margin="0" Background="{Binding Color}">
                                        <Ellipse Width="8" Height="8" Stroke="{Binding ForeColor}" Fill="{Binding ForeColor}"
                                                 Opacity="0"/>
                                    </Grid>
                                </DataTemplate>
                            </sdk:DataGridTemplateColumn.CellTemplate>
                        </sdk:DataGridTemplateColumn>
                    </sdk:DataGrid.Columns>
                </sdk:DataGrid>
                <sdk:DataPager x:Name="ShiftsPager" Source="{Binding Data, ElementName=ShiftsDataSource}" PageSize="10"/>
            </StackPanel>
        </ScrollViewer>
    </Grid>
</navigation:Page>
